package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         122,
		Discription: "无限笔股票买卖最大收益",
		Level:       1,
		Labels: map[string]int{
			"贪心": 1,
		},
	})
}

func MaxProfit2(prices []int) int {
	sum := 0
	for i := 1; i < len(prices); i++ {
		if prices[i] > prices[i-1] {
			sum += prices[i] - prices[i-1]
		}
	}

	return sum
}
